/**
 * 功能描述�?
 */
define(function (require, exports, module) {
    //引入视图基类
    var ELView = require("elview");
    var aw = require("ajaxwrapper");

    //assets
    var template = require("./assets/tpl/nonmemsignup_main.tpl");
    require("./assets/css/nonmemsignup_main.css");

    //business

    //component
    var nonMemSubnav = require("./component/nonMemSubnav.js");
    var nonMemGrid = require("./component/nonMemGrid.js");
    var nonMemEditGrid = require("./component/nonMemEditGrid.js");
    var nonMemForm = require("./component/nonMemForm.js");
    var experienceSubnav = require("./component/experienceSubnav.js");
    var experienceGrid = require("./component/experienceGrid.js");
    var experienceForm = require("./component/experienceForm.js");
    var nonMemPerForm = require("./component/nonMemPerForm.js");
    var nonMemPerGrid = require("./component/nonMemPerGrid.js");
    var reservegrid = require("./component/reservegrid.js");

    //constant

    //handler

    //store

    var App = ELView.extend({
        attrs: {
            template: template
        },
        initComponent: function (params, widget) {
        	if(params.type == "NonMember"){
        		nonMemSubnav.initComponent(params, widget);
        		nonMemGrid.initComponent(params, widget);
        		nonMemEditGrid.initComponent(params, widget);
        		nonMemForm.initComponent(params, widget);
        		reservegrid.initComponent(params, widget);
        	}
        	if(params.type == "Experience"){
        		experienceSubnav.initComponent(params, widget);
        		experienceGrid.initComponent(params, widget);
        		experienceForm.initComponent(params, widget);
        		nonMemPerForm.initComponent(params, widget);
            	nonMemPerGrid.initComponent(params, widget);
        	}
        	
        },
        afterInitComponent: function (params, widget) {
        	if(params.type == "NonMember"){
        		widget.set("type", "NonMember");
        	}else{
        		widget.set("type", "Experience");
        	}
        	
        	aw.ajax({
				url : "api/servicepoint/operableservicepoints",
				dataType:"json",
				data : {},
				success:function(data){
					widget.get("form").setData("servicePoint",data);
					if(params.type == "NonMember"){
						widget.get("subnav").setData("servicePoint",data);
					}
					$("th[data-name='signUpRegister.travelContract.memberCertificates']").hide();
					$(".J-grid-columns-signUpRegister-travelContract-memberCertificates").addClass("hidden");
					widget.get("grid").refresh();
				}
        	});
        }
    });

    module.exports = App;
});
